package com.yssystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.yssystem.domain.Do.SysDeptDO;
import com.yssystem.domain.SysDept;
import com.yssystem.service.SysDeptService;
import com.yssystem.mapper.SysDeptMapper;
import com.yssystem.utils.TreeDeptUtil;
import com.yssystem.utils.TreeMenuUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
* @author 28783
* @description 针对表【sys_dept(组织机构)】的数据库操作Service实现
* @createDate 2024-07-12 10:37:42
*/
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
    implements SysDeptService{
    public List<SysDeptDO> getList(){
        List<SysDept> list = list();

        List<SysDeptDO> list1 = new ArrayList<>();
        for ( SysDept e :list) {
//            System.out.println(e);
            SysDeptDO sysDeptDO = new SysDeptDO();

            BeanUtils.copyProperties(e,sysDeptDO);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            // 将日期对象转换为指定格式的字符串
            String formattedDate = sdf.format(sysDeptDO.getCreateTime());
            sysDeptDO.setTime(formattedDate);
            list1.add(sysDeptDO);
        }
//        System.out.println(list1);
        List<SysDeptDO> list2 = TreeDeptUtil.createTree(list1, 0);
        return list2;
    }

}




